﻿using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using System.Web.UI.HtmlControls;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class RC_BackManageOld : System.Web.UI.Page
    {
     
        protected void Page_Load(object sender, EventArgs e)
        {

            IncludeJava();


            if (!Page.IsPostBack)
            {


                if (Request.QueryString["cmd_seq"] != null)
                    Session["cmd_seq"] = Request.QueryString["cmd_seq"];


                if (Request.QueryString["cmd_name"] != null)
                    lblCmdName.Text = Request.QueryString["cmd_name"];

                if (Request.QueryString["cmd_ref_no"] != null)
                    lblRefNo.Text = Request.QueryString["cmd_ref_no"];

                if (Request.QueryString["approved_date"] != null)
                    lblAppDate.Text = Request.QueryString["approved_date"];

                LoadDataGrid();
            }

        }
        public void LoadDataGrid()
        {
                      

              DataTable dt;



              RC_BackManageOldBLL obj = new RC_BackManageOldBLL();
            int cmd_seq;
            cmd_seq = int.Parse(Session["cmd_seq"].ToString());   
            dt = obj.Select(cmd_seq); 
                

            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();


        }

        public void IncludeJava()
        {
            HtmlGenericControl script = new HtmlGenericControl();
            script.TagName = "script";
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", "../../Scripts/jsfunction.js");
            Page.Header.Controls.Add(script);
        }

        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {

            if (e.CommandName == "btnClick")
                return;


            if (e.CommandName == "Delete")
            {
                int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cmd_dtls_seq"]);


                RC_BackManageOldBLL obj = new RC_BackManageOldBLL();
                obj.Delete(seq, 1);
           
            }
            LoadDataGrid();
        }

        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridCommandItem)
            {
                GridCommandItem commandItem = e.Item as GridCommandItem;
                LinkButton button = commandItem.FindControl("cmdAddNew") as LinkButton;

                if (this.lblSta.Text == "v")
                {
                    button.Enabled = false;
                    button.Visible = true;
                    button.Text = "";
                }
            }
        }

        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (this.lblSta.Text == "v")
            {
                RadGrid1.Columns[0].Visible = false;
                RadGrid1.Columns[1].Visible = false;
            }
        }

        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {

        }
    }
}
